<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DIV+CSS+JS二级树型菜单，展开后刷新无影响</title>
<style type="text/css">
<!--
body { font-family: arial, 宋体, serif; font-size:12px; padding-top:13px }
* { margin:0px; padding:0px; }
#nav { width:130px; line-height: 23px; list-style-type: none; text-align:left; /*定义整个ul菜单的行高和背景色*/
}
/*==================一级目录===================*/
#nav a { width: 140px; display: block; padding-left:10px; /*Width(一定要)，否则下面的Li会变形*/
}
#nav li {float:left; background:url(../images/title-bg.gif) repeat-x; color:#226399; font-weight:bold; }
.blank {border:#93b2ce 1px solid; margin-top:1px}
#nav li a:hover { background:#b2ceef; /*一级目录onMouseOver显示的背景色*/ }
#nav a:link { color:#226399; text-decoration:none; }
#nav a:visited { color:#226399; text-decoration:none; }
#nav a:hover { color:#FFF; text-decoration:none; font-weight:bold; }
/*==================二级目录===================*/
#nav li ul { list-style:none; text-align:left; }
#nav li ul li { background:#eaf2f8; /*二级目录的背景色*/ font-weight:normal; }
#nav li ul a { padding-left:20px; width:130px;/* padding-left二级目录中文字向右移动，但Width必须重新设置=(总宽度-padding-left)*/
}
/*下面是二级目录的链接样式*/
#nav li ul a:link { color:#226399; text-decoration:none; }
#nav li ul a:visited { color:#226399; text-decoration:none; }
#nav li ul a:hover { color:#226399; text-decoration:none; font-weight:normal; background:#dee8f1;/* 二级onmouseover的字体颜色、背景色*/
}
/*==============================*/
#nav li:hover ul { left: auto; }
#nav li.sfhover ul { left: auto; }
#content { clear: left; }
#nav ul.collapsed { display: none; }
-->
#PARENT { width:130px; margin-left:5px}
</style>
</head>
<body>
<div style="width:580px;">
    <div id="PARENT" style="float:left">
    <ul id="nav">
        <li class=" blank"><a href="#Menu=ChildMenu1" onclick="DoMenu('ChildMenu1')">订单管理</a>
          <ul id="ChildMenu1" class="collapsed">
            <li style=" border-top:#93b2ce 1px solid"><a href="toAddOrders.do" target="mainFrame">添加订单</a></li>
            <li><a href="listOrders.do" target="mainFrame">查看订单</a></li>
          </ul>
        </li>
       <li class=" blank"><a href="#Menu=ChildMenu6" onclick="DoMenu('ChildMenu6')">用户管理</a>
          <ul id="ChildMenu6" class="collapsed">
            <li style=" border-top:#93b2ce 1px solid"><a href="getUserList.do" target="mainFrame">用户列表</a></li> 
			<li><a href="addUser.do" target="mainFrame">添加用户</a></li> 
          </ul>
        </li>
        <li class=" blank"><a href="#Menu=ChildMenu2" onclick="DoMenu('ChildMenu2')">购买服务</a>
          <ul id="ChildMenu2" class="collapsed">
            <li style=" border-top:#93b2ce 1px solid"><a href="buyHistoryList.do" target="mainFrame">购买历史</a></li>
          </ul>
        </li>
       <li class=" blank"><a href="#Menu=ChildMenu3" onclick="DoMenu('ChildMenu3')">建议管理</a>
          <ul id="ChildMenu3" class="collapsed">
            <li style=" border-top:#93b2ce 1px solid"><a href="toAddSuggestion.do" target="mainFrame">提出建议</a></li>
            <li><a href="listSuggestion.do" target="mainFrame">所有建议</a></li>
            <li><a href="listRepliedSuggestion.do" target="mainFrame">已回复建议</a></li>
          </ul>
        </li>
        <li class=" blank"><a href="#Menu=ChildMenu4" onclick="DoMenu('ChildMenu4')">公司信息修改</a>
          <ul id="ChildMenu4" class="collapsed">
            <li style=" border-top:#93b2ce 1px solid"><a href="toEditAdminUser.do" target="mainFrame">公司基本信息</a></li>
             <li style=" border-top:#93b2ce 1px solid"><a href="toEditPassword.do" target="mainFrame">修改密码</a></li>
          </ul>
        </li>
    </ul>
    </div>
</div>
<script type=text/javascript><!--
var LastLeftID = "";
function menuFix() {
var obj = document.getElementById("nav").getElementsByTagName("li");

for (var i=0; i<obj.length; i++) {
obj[i].onmouseover=function() {
   this.className+=(this.className.length>0? " ": "") + "sfhover";
}
obj[i].onMouseDown=function() {
   this.className+=(this.className.length>0? " ": "") + "sfhover";
}
obj[i].onMouseUp=function() {
   this.className+=(this.className.length>0? " ": "") + "sfhover";
}
obj[i].onmouseout=function() {
   this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
}
}
}
function DoMenu(emid)
{
var obj = document.getElementById(emid); 
obj.className = (obj.className.toLowerCase() == "expanded"?"collapsed":"expanded");
if((LastLeftID!="")&&(emid!=LastLeftID)) //关闭上一个Menu
{
document.getElementById(LastLeftID).className = "collapsed";
}
LastLeftID = emid;
}
function GetMenuID()
{
var MenuID="";
var _paramStr = new String(window.location.href);
var _sharpPos = _paramStr.indexOf("#");

if (_sharpPos >= 0 && _sharpPos < _paramStr.length - 1)
{
_paramStr = _paramStr.substring(_sharpPos + 1, _paramStr.length);
}
else
{
_paramStr = "";
}

if (_paramStr.length > 0)
{
var _paramArr = _paramStr.split("&");
if (_paramArr.length>0)
{
   var _paramKeyVal = _paramArr[0].split("=");
   if (_paramKeyVal.length>0)
   {
    MenuID = _paramKeyVal[1];
   }
}
/*
if (_paramArr.length>0)
{
   var _arr = new Array(_paramArr.length);
}

//取所有#后面的，菜单只需用到Menu
//for (var i = 0; i < _paramArr.length; i++)
{
   var _paramKeyVal = _paramArr[i].split('=');
   
   if (_paramKeyVal.length>0)
   {
    _arr[_paramKeyVal[0]] = _paramKeyVal[1];
   } 
}
*/
}

if(MenuID!="")
{
DoMenu(MenuID)
}
}
GetMenuID(); //*这两个function的顺序要注意一下，不然在Firefox里GetMenuID()不起效果
menuFix();
--></script>
</body>
</html>
